import Vue from 'vue';
import Router from 'vue-router';

Vue.use(Router);

export default new Router({
    routes: [
        {
            path:'/',
            redirect: '/index',
        },
        {
            path: '/open',
            //home组件是后台的根组件
            component: resolve => require(['../components/common/Home.vue'], resolve),
            redirect: '/open/account',
            children:[
                {
                    path: 'account',
                    component: resolve => require(['../components/page/account.vue'], resolve),
                },
                {
                    path: 'product',
                    component: resolve => require(['../components/page/product.vue'], resolve),
                },
                {
                    path: 'selectRequest',
                    component: resolve => require(['../components/page/selectRequest.vue'], resolve),
                },
                {
                    path: 'product/Add',
                    component: resolve => require(['../components/page/productAdd.vue'], resolve),
                },
                {
                    path: 'product/Edit/:pid',
                    component: resolve => require(['../components/page/productEdit.vue'], resolve),
                },
                {
                    path: 'team',
                    component: resolve => require(['../components/page/team.vue'], resolve),
                },                
                {
                    path: 'team/Add',
                    component: resolve => require(['../components/page/teamAdd.vue'], resolve),
                }, 
                {
                    path: 'team/Edit/:uid',
                    component: resolve => require(['../components/page/teamEdit.vue'], resolve),
                },
                {
                    path: 'testCase',
                    component: resolve => require(['../components/page/testCase.vue'], resolve),
                },
                {
                    // 富文本编辑器组件
                    path: 'editor',
                    component: resolve => require(['../components/page/VueEditor.vue'], resolve),
                    meta: { title: '富文本编辑器' }
                },
                {
                    // markdown组件
                    path: 'markdown',
                    component: resolve => require(['../components/page/Markdown.vue'], resolve),
                    meta: { title: 'markdown编辑器' }    
                },
                {
                    // 图片上传组件
                    path: 'upload',
                    component: resolve => require(['../components/page/Upload.vue'], resolve),
                    meta: { title: '文件上传' }   
                },
                {
                    // vue-schart组件
                    path: 'charts',
                    component: resolve => require(['../components/page/BaseCharts.vue'], resolve),
                    meta: { title: 'schart图表' }
                },
                {
                    // 拖拽列表组件
                    path: 'drag',
                    component: resolve => require(['../components/page/DragList.vue'], resolve),
                    meta: { title: '拖拽列表' }
                },
                {
                    // 权限页面
                    path: 'permission',
                    component: resolve => require(['../components/page/Permission.vue'], resolve),
                    meta: { title: '权限测试', permission: true }
                }
            ]
        },
        {
            path: '/login',
            component: resolve => require(['../components/page/Login.vue'], resolve)
        },
        {
            path: '/api',
            component: resolve => require(['../components/common/api.vue'], resolve),
            children:[
                {
                    path:'introduce',
                    component: resolve => require(['../components/api/introduce.vue'], resolve),
                }
            ]
        },
        {
            path: '/index',
            component: resolve => require(['../components/page/index.vue'], resolve)
        },
        {
            path: '/403',
            component: resolve => require(['../components/page/403.vue'], resolve)
        },
        {
            path: '*',
            component: resolve => require(['../components/page/404.vue'], resolve)
        }
    ]
})
